package com.ruoyi.system.utils;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.system.domain.vo.PageInfo;
import java.util.List;
import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM;
import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE;

public class MyPageUtils {

    public static <T>  PageInfo<T> startPage(List<T> list) {

        Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM));
        Integer pageSize= Convert.toInt(ServletUtils.getParameter(PAGE_SIZE));
        int start = Math.min((pageNum - 1) * pageSize, list.size());
        //  终点
        int end = Math.min(pageNum * pageSize, list.size());
       return new PageInfo<>(list.size(),list.subList(start,end));
    }
}
